package Demo2;

public class Booklist {
    //实例化Book类型的数组
    Book[] book = new Book[10];//书架容量，10

    //创建一个记录当前书籍数的变量
    private int count;
    //在构造方法中先存放一些书籍，例如四大名著
    public Booklist(){
        book[0] = new Book("西游记","吴承恩","长篇小说",832.50);
        book[1] = new Book("红楼梦","曹雪芹","长篇小说",51.90);
        book[2] = new Book("三国演义","罗贯中","长篇小说",43.80);
        book[3] = new Book("水浒传","施耐庵","长篇小说",496.00);
        this.count = 4;
    }
    //set方法
    //将新的引用赋给当前下标的引用
    public void setBook(int pos,Book book) {
        this.book[pos] = book;
    }
    public void setCount(int count) {
        this.count = count;
    };
    //将后面的引用赋给前面的引用，在删除功能中使用
    public void setBook(Book[] book,int pos) {
        this.book[pos] = book[pos+1];
    }

    //get方法
//得到当前书籍的引用
    public Book[] getBook() {
        return book;
    }
//获取当前下标数的引用
public Book getBook(int pos){
        return book[pos];
}
//获取当前书架上的书籍数
    public int getCount() {
        return count;
    }
}
